<template>
  <div class="company">
    <van-swipe
      class="my-swipe"
      :autoplay="3000"
      indicator-color="white"
      v-if="data.morepic"
    >
      <van-swipe-item
        v-for="(item,index) in data.morepic"
        :key="index"
        lazy-render
      >
        <img :src="item.tpic">
      </van-swipe-item>
    </van-swipe>
    <img
      v-else
      src="@/assets/img/7.jpg"
      class="imgWidth"
    >
    <div class="docking">
      <div class="dockingBox flex align_center justify_between">
        <div class="docking_left">
          <div class="flex align_center">
            <div>
              <img :src="data.head_img ? data.head_img : logo_z">
            </div>
            <div>
              <p class="contenr3 fontBold color1">
                {{ data.company }}
              </p>
              <p class="content3 font400 color3 line20">
                {{ data.address }}
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      class="company_content font400 content3 color3"
      v-if="data.content"
      v-html="data.content"
    />
  </div>
  <div class="fexd_footer">
    <div class="footer_btn flex align_center justify_between">
      <div class="flex align_center">
        <div
          @click="back"
          class="agree font400 content3 color4"
        >
          返回
        </div>
      </div>
    </div>
  </div>
  <!-- <div class="fexd_footer">
    <div class="footer_btn flex align_center justify_between">
      <div
        class="font400 content3 color4"
        @click="back"
      >
        <svg
          class="icon"
          aria-hidden="true"
        >
          <use xlink:href="#icon-fanhui" />
        </svg>
        <p class="content2 font400 color3">
          返回
        </p>
      </div>
      <div
        class="font400 content3 color4"
        @click="share"
      >
        <svg
          class="icon"
          aria-hidden="true"
        >
          <use xlink:href="#icon-fenxiang" />
        </svg>
        <p class="content2 font400 color3">
          分享
        </p>
      </div>
      <div
        @click="submit"
        class="agree font400 content3 color4"
      >
        联系企业
      </div>
    </div>
  </div> -->
  <van-dialog
    v-model:show="show"
    title="温馨提示"
    confirm-button-color="#FF7A1F"
  >
    <div class="Scan">
      <p class="font400 content3 color3">
        您可长按添加工作人员微信 与我们取得联系
      </p>
      <img src="@/assets/img/no-content-color.png">
    </div>
  </van-dialog>
  <Loading
    :visible="visible"
    :share-img="shareImg"
    @closeLoading="closeLoading"
  />
</template>

<script setup lang="ts">
import { ref, defineAsyncComponent } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from 'vuex'
import { squareCompanyDetail } from '@/api'
import logo_z from '@/assets/img/logo-z.jpg'
// import { Toast } from 'vant' companyShare
const Loading = defineAsyncComponent(() => import('@/components/Loading/index.vue'))
const router = useRouter()
const route = useRoute()
const store = useStore()
const data: any = ref([])
const show: any = ref(false)
const visible: any = ref(false)
const shareImg: any = ref('')

const getData = async () => {
  data.value = await squareCompanyDetail({ company_id: route.query.id })
}
getData()
const back = () => {
  if (store.state.from.path !== '/') {
    router.back()
  } else {
    router.replace('/')
  }
}

// const submit = () => {
//   show.value = true
//   // router.push('/square/contacts')
// }

const closeLoading = async () => {
  visible.value = false
}
// const share = async () => {
//   try {
//     visible.value = true
//     await companyShare({ company_id: route.query.id, web_url: encodeURIComponent(window.location.href) })
//     shareImg.value = `${import.meta.env.VITE_API_BASEURL}v1/square_company/share?company_id=${route.query.id}&web_url=${encodeURIComponent(window.location.href)}`
//   } catch (error:any) {
//     Toast(error.message)
//   }
// }
</script>

<style lang="less" scoped>
.company {
  padding: 0 15px 80px;
  .company_content {
    margin-top: 20px;
    padding: 15px;
    background-color: #fff;
    border-radius: 5px;
    line-height: 25px;
  }
}
.docking {
  width: 100%;
  background: #ffffff;
  border-radius: 10px;
  margin: 15px 0;
  .dockingBox {
    padding: 15px;
    .docking_left {
      img {
        width: 70px;
        height: 70px;
        border-radius: 5px;
        object-fit: cover;
        margin-right: 15px;
      }
      p {
        width: 100%;
      }
      p:last-child {
        margin-top: 10px;
      }
    }
  }
}
.imgWidth{
  width: 340px;
  height: 146px;
    border-radius: 5px;
  margin: 16px auto;
  object-fit: cover;
}
.my-swipe {
  width: 340px;
  height: 146px;
  // background: #ff7a1f;
  // box-shadow: 0px 2px 10px 0px rgba(238, 150, 103, 0.5);
  border-radius: 5px;
  margin: 16px auto;
  img {
    width: 100%;
    height: 146px;
    object-fit: cover;
  }
}
.Scan {
  p {
    width: 190px;
    margin: 18px auto;
    text-align: center;
    line-height: 20px;
  }
  img {
    width: 95px;
    height: 95px;
    object-fit: contain;
    margin: 0 auto;
  }
}

.fexd_footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background-color: #fff;
    box-shadow: 0px 2px 12px 2px rgba(22, 12, 6, 0.09);
    .footer_btn {
        padding: 0 30px;
        height: 100%;
        text-align: center;
        .agree {
            width: 315px;
            height: 44px;
            background: #85898C;
            border-radius: 5px;
            text-align: center;
            line-height: 44px;
        }
    }
}
@media (min-width: 750px) {
  .company {
  padding: 0 15px 80px;
  .company_content {
    margin-top: 20px;
    padding: 15px;
    background-color: #fff;
    border-radius: 5px;
    line-height: 25px;
  }
}
.docking {
  width: 100%;
  background: #ffffff;
  border-radius: 10px;
  margin: 15px 0;
  .dockingBox {
    padding: 15px;
    .docking_left {
      img {
        width: 70px;
        height: 70px;
        border-radius: 5px;
        object-fit: cover;
        margin-right: 15px;
      }
      p {
        width: 100%;
      }
      p:last-child {
        margin-top: 10px;
      }
    }
  }
}
.imgWidth{
  width: 340px;
  height: 146px;
    border-radius: 5px;
  margin: 16px auto;
  object-fit: cover;
}
.my-swipe {
  width: 340px;
  height: 146px;
  // background: #ff7a1f;
  // box-shadow: 0px 2px 10px 0px rgba(238, 150, 103, 0.5);
  border-radius: 5px;
  margin: 16px auto;
  img {
    width: 100%;
    height: 146px;
    object-fit: cover;
  }
}
.Scan {
  p {
    width: 190px;
    margin: 18px auto;
    text-align: center;
    line-height: 20px;
  }
  img {
    width: 95px;
    height: 95px;
    object-fit: contain;
    margin: 0 auto;
  }
}

.fexd_footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background-color: #fff;
    box-shadow: 0px 2px 12px 2px rgba(22, 12, 6, 0.09);
    .footer_btn {
        padding: 0 30px;
        height: 100%;
        text-align: center;
        .agree {
            width: 315px;
            height: 44px;
            background: #85898C;
            border-radius: 5px;
            text-align: center;
            line-height: 44px;
        }
    }
}
}
// .fexd_footer {
//   position: fixed;
//   bottom: 0;
//   left: 0;
//   width: 100%;
//   height: 70px;
//   background-color: #fff;
//   box-shadow: 0px 2px 12px 2px rgba(22, 12, 6, 0.09);
//   .footer_btn {
//     padding: 0 30px;
//     height: 100%;
//     text-align: center;
//     .agree {
//       width: 189px;
//       height: 44px;
//       background: #ff7a1f;
//       border-radius: 5px;
//       text-align: center;
//       line-height: 44px;
//     }
//     .icon {
//       width: 23px;
//       height: 23px;
//       margin-bottom: 2px;
//     }
//   }
// }
</style>
